package com.sz.app.edi.web.swagger;

import com.sz.biz.app.utils.SwaggerUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/**
 * Function: Swagger2 <br>
 * Author: Charles <br>
 * Date: 2017-04-30 12:11:00
 */
@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {

       /** ParameterBuilder clientIdParam = new ParameterBuilder();
        List<Parameter> pars = new ArrayList<>();
        clientIdParam.name("clientId").description("client id").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
        pars.add(clientIdParam.build());*/
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(SwaggerUtils.basePackages(new String[]{"com.sz.biz.app.web.api", "com.sz.app.edi.rest"}))
                .paths(PathSelectors.any())
                .build()/*.globalOperationParameters(pars)*/;
    }





    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Logistics platform EDI system RESTful APIs")
                .description("Logistics platform EDI system RESTful APIs document")
                .termsOfServiceUrl("http://xxxx.com/")
                .contact(new Contact("Charles", "http://www.logistics.biz", "qianb.li@hnair.com"))
                .version("1.0")
                .build();
    }


}